package com.petter.security;

import com.petter.core.entry.User;
import com.petter.security.config.MyBeanPostProcessor;
import com.petter.security.service.circularDependency.structure.Service4;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author GD
 */
@SpringBootApplication
@Controller
public class SecurityApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SecurityApplication.class, args);
        System.out.println(context.getBean("user2"));
        System.out.println(context.getBean("user"));
        MyBeanPostProcessor bean = context.getBean(MyBeanPostProcessor.class);
        bean.printCount();
        Service4 server1 = (Service4) context.getBean("service1");
        System.out.println(server1);
    }

    @RequestMapping("test")
    @ResponseBody
    public String test(){
        return "hello";
    }


    @Bean
    public User user(){
        User user = new User();
        user.setNumber("111");
        user.setPassword("password");
        return user;
    }
}
